﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using StreamingClient.Localization;

namespace StreamingClient.StreamManagment
{
    public partial class SettingsCtrl : UserControl
    {
        private SettingsVM _settingsVM;

        public static readonly DependencyProperty StreamingSettingsProperty =
            DependencyProperty.Register("StreamingSettings", typeof (StreamingSettings), typeof (SettingsCtrl),
                                        new PropertyMetadata(StreamingSettingsChanged));

        private static void StreamingSettingsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var value = e.NewValue as StreamingSettings;
            var settingsCtrl = (SettingsCtrl) d;
            
            if (value == null)
            {
                settingsCtrl._settingsVM = null;
            }
            else
            {
                settingsCtrl._settingsVM = new SettingsVM(value);
            }
            settingsCtrl.LayoutRoot.DataContext = settingsCtrl._settingsVM;
        }

        public StreamingSettings StreamingSettings
        {
            get { return (StreamingSettings)GetValue(StreamingSettingsProperty); }
            set { SetValue(StreamingSettingsProperty, value); }
        }

        public Visibility ServerTypeVisibility { get { return ServerType.Visibility; } set { ServerType.Visibility = value; } }

        public SettingsCtrl()
        {
            

            InitializeComponent();
        }
    }
}
